package com.qf.controller;

import com.qf.pojo.Goods;
import org.springframework.web.bind.annotation.*;

/**
 * @author 千峰教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @GetMapping("/index")
    public String index(){
//        System.out.println(1/0);
        return "获取商品 :  9001";
    }


    @GetMapping("/findById/{goodsId}")
    public Goods findById(@PathVariable("goodsId") Integer id){
        return new Goods(id, "手办", System.currentTimeMillis());
    }

    @GetMapping("/findById")
    public Goods findById2(Integer id){
        System.out.println(1/id);
        return new Goods(id, "手办", 500);
    }

    @PostMapping("/save")
    public String save(@RequestBody Goods goods){
        System.out.println("qf-goods -- 保存商品对象：" + goods);
        return "success";
    }
}
